< previous page page_103 next page >

Page 103
Public Sub verifyCheckAccountHistory(SomeCustomerSSN)
     theCheckingAccountHistoryInfo.verify(SomeCustomerSSN)
End Sub
Delegation is synonymous with the uses relationship as defined in the Unified Modeling Language. That is, when one object delegates some or all of its responsibilities to another object, the former object is using that latter object.
Also, Visual Basic doesn't support the kind of polymorphism associated with inheritance lattices. In other words, if a superclass named theSuperClass has a method called print, and a subclass of theSuperClass, theSubclass, also has a specialized (or customized) method called print, and, in turn, a subclass of the theSubclass has a specialized method named print, the compiler would use the specialized method of the class instance being used for a given context (or section of code). With the absence of implementation inheritance and full interface inheritance, this kind of polymorphism is practically nonexistent. (Of course, a class's interface can be inherited one level down as if it were a pure virtual base class, but Visual Basic expects the public methods and properties to be implemented by the client class.)
Visual Basic supports the other kind of polymorphism, in which a collection of objects with one or more methods of the same name will have varying behaviors when iterated. That is, using the Samsona Bank Teller System example, suppose you have collection of history verification objects, theCheckingAccountHistoryInfo and theCreditHistoryInfo. As you saw in the previous chapter, each of these objects has a method called verify. Let's create a collection object called HistoryVerifiers. Here are the steps for creating such a collection object:
1. Start a new project in Visual Basic.
2. Create a class called CheckingAccountHistoryInfo and a class called CreditHistoryInfo. Using either Rational Rose/Visual Basic or Visual Modeler, you can generate them by choosing Tools | Code Generation Wizard from the menu of either application.
Background on Code Generation in Rational Rose and Visual Modeler
Automating the process of creating object-oriented programming code considerably reduces the normal risks associated with software development projects. Such risks include the obvious human error factor in coding, the risk of not properly transitioning from a model to the actual code base, the risk of not properly documenting code, and so on. Both Rational Rose/Visual Basic and Microsoft Visual Modeler offer automated code

 
< previous page page_103 next page >

If you like this book, buy it!